# 使用Maven 3.9.2和JDK 17构建阶段
FROM maven:3.9.3-eclipse-temurin-17 AS build
WORKDIR /mall4j-master/yami-shop-admin

# 复制源代码和构建配置到构建阶段的工作目录
COPY src /mall4j-master/yami-shop-api/src
COPY pom.xml settings.xml /mall4j-master/

# 执行Maven构建命令
RUN mvn -s /mall4j-master/settings.xml -f /mall4j-master/pom.xml clean package


FROM openjdk:17.0.2

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

RUN mkdir -p /opt/projects/mall4j

WORKDIR /opt/projects/mall4j

EXPOSE 8086

ADD ./yami-shop-api/target/yami-shop-api-0.0.1-SNAPSHOT.jar ./

CMD java -jar -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio=8 -Dspring.profiles.active=prod yami-shop-api-0.0.1-SNAPSHOT.jar
